package com.lyk.coursearrange.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lyk.coursearrange.entity.Job;
import com.lyk.coursearrange.entity.Teacher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lyk.coursearrange.entity.dto.TeacherDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lequal
 * @since 2020-03-13
 */
@Mapper
public interface TeacherDao extends BaseMapper<Teacher> {

    @Select("SELECT * FROM tb_teacher WHERE teacher_no=#{account} AND password=#{password}" +
            "        UNION" +
            "        SELECT * FROM tb_teacher WHERE username=#{account} AND password=#{password}" +
            "        UNION" +
            "        SELECT * FROM tb_teacher WHERE realname=#{account} AND password=#{password}")
    Teacher teacherLogin(@Param("account") String account, @Param("password") String password);

    @Select("select count(*) from tb_teacher where date(create_time) = #{yesday}")
    int teacherReg(@Param("yesday") String yesday);
    @Select("SELECT id,realname FROM `tb_teacher`")
    List<TeacherDto> getteacherlist();

    @Select("SELECT realname FROM `tb_teacher` where id = #{customerTeacherid}")
    String getteacherName(@Param("customerTeacherid") Long customerTeacherid);


    List<Teacher> queryTeacher(@Param("page") Long offset,@Param("limit") Long limit,@Param("realname")String realname);

    Long teachercount(@Param("realname")String realname);

    String getJobName(@Param("job_id") Long jobtitle);
    @Select("SELECT * FROM `tb_job`")
    List<Job> queryTeacherJob();


    boolean addTeacher(@Param("t") Teacher teacher);
}
